package com.techsoul.module.tms.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.techsoul.module.tms.pojo.entity.FreightVehicleDistribution;
import com.techsoul.module.tms.pojo.param.FreightVehicleDistributionSearchParam;

import com.techsoul.module.tms.pojo.vo.*;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.List;

/**
 * <p>
 * 配载单明细表 Mapper 接口
 * </p>
 *
 * @author zhaowei
 * @since 2021-07-23
 */
public interface FreightVehicleDistributionMapper extends BaseMapper<FreightVehicleDistribution> {
    /**
     * Find all list.
     *
     * @param params the params
     * @return the list
     */
    List<FreightVehicleDistributionVo> findAll(@Param("params") FreightVehicleDistributionSearchParam params);

    List<FreightVehicleDistributionVo> findByDispatchId(@Param("dispatchId") String dispatchId);

    List<FreightVehicleDistribution> findByOrderLineItemId(@Param("itemid") String itemid);

    /**
     * Find all page.
     *
     * @param page   the page
     * @param params the params
     * @return the page
     */
    IPage<FreightVehicleDistributionVo> findAll(Page<FreightVehicleDistributionVo> page,
                                                @Param("params") FreightVehicleDistributionSearchParam params);


    BigDecimal getSumVol(@Param("dispatchId") String dispatchId);

    BigDecimal getSumQuantityWithStatus(@Param("itemId") String itemId, @Param("status") String status);

    BigDecimal getSumWeightWithStatus(@Param("itemId") String itemId, @Param("status") String status);

    BigDecimal getSumVolumeWithStatus(@Param("itemId") String itemId, @Param("status") String status);

    BigDecimal getSumPackQtyWithStatus(@Param("itemId") String itemId, @Param("status") String status);

    BigInteger countTotalLines(@Param("dispatchId") String dispatchId);

    BigInteger countStatusForDeliveryOrReturnedOrClosed(@Param("dispatchId") String dispatchId);

    List<FreightVehicleDistributionVo> findEntityByDispatchId(@Param("dispatchId") String dispatchId);
}
